#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void swap(int* a, int* b)
{
	int c = *a;
	*a = *b;
	*b = c;
}

void quicksort(int* a, int left, int right)
{
	if (left >= right)
	{
		return;
	}
	int begin = left;
	int end = right;
	int ki = begin;
	while (begin<end)
	{
		while (left<right && a[end]>a[ki])
		{
			end--;
		}
		while (left < right && a[begin] < a[ki])
		{
			begin++;
		}
		swap(&a[begin], &a[end]);
	}
	swap(&a[begin], &a[ki]);
	quicksort(a, left, begin - 1);
	quicksort(a, begin+1, right);
}
int main()
{
	int a[6] = { 5,3,2,1,0,9 };
	quicksort(a, 0, 5);
	for (int i = 0; i < 6; i++)
	{
		printf("%d ", a[i]);
	}
	return 0;
}